<?php
/**
* 支付宝获取接口
* @author ldward
* @date 2018.08.23
* @copyright leemanpaper.com
*/
include_once ROOT_DIR . "/custom/lib/alipay-sdk-PHP-3.3.0/aop/AopClient.php";
include_once ROOT_DIR . "/custom/lib/alipay-sdk-PHP-3.3.0/aop/SignData.php";
include_once ROOT_DIR . "/custom/lib/alipay-sdk-PHP-3.3.0/aop/request/AlipayTradeQueryRequest.php";
class erpapi_rpc_alipay
{
    
    /*
    * 请求
    * @param string $method 接口方法
    * @param array $params
    * @return array 接口返回
    */
    public function call($method, $params)
    {
        $rsaPrivateKey="MIIEpAIBAAKCAQEAn0DVYzNXhwFBAgfAfD7QP/h+1DmzFxXrDpjLEY/98VNDK6gD
qTClF+Q6jqfv5ny/coyxl4vQfJYfUxJA+LXIQ0r+/M9GVGCYH7NtOQSmYKPvnZNV
2jzMGZNFX1Unf5vn6hjM5briY5+Thu7L4iXzhv7tafdgvAqqEGMqb9OJdktNc6dX
hCX/4vi+i3lXZQrlZv/+FSRuOqxuVpR2z02eWaUCpzJUoAPVwOnt1EVypsiDQQNt
ZJ8rYF3tMyhQeFNVEwE6qTF18UkflC1QldWE80wtidHA/b/DyUVivI2eniXaj5As
7W1ZLXjmuQK43tg+C9VpBRN+Ew9irBcwKynZJwIDAQABAoIBAQCEVEI8GPh9FRyo
jDp0w1kWHu18eamH4E2epnXu1QCFW9Nv3j+UgfhdHudNjNx6YGRQ0fnr3GDUdYX3
6C4WvC55REMXXUCqck1V4ik6/NMncHF2NWxcWLKb+dTmP4L/tVQDILJ5nk3pzDqx
H5JJC5INNZ2ftNAr0Iy56zzjCRqrMN3EIjlD1yZAwcw0qBEEsC1ukl/hDXTxUPC0
xrI2d6DW/Is4u17BNpV2oK68yNj81DIocG8hgffBHQVoiO2WUvO6yLeK36U8EWUb
YZxtmVA4fnXmGrpmSPquzUI20X1kvePxJBuSpOn8OS9ZC/psaBgpvOBc1L40M4DL
rRkrVuR5AoGBAM0lOSGCP0DM9YgN7+YgCxzdYCJs7/P5bzHrv+ShhfzOLdyHnbb5
RZmasKNbkevOC1g7BxWOwpUlyk+Jsirh2kFnrRK6kV0kFbbvj/KqNXZmbwP5apSG
m6o9nDaEGCz9LNUCDQDOFR4w+O7ENCOw4GLyYLa82Jn1TF5OzNhWkBTzAoGBAMa7
PSjIiJv9NJK0+CMtqtnA8Qb/dALRlltMme+fqUaICCwmEKhd5T65dQKYq3OaOYlg
xI8SaNaxUbOIa+5a5Sud/qYUW+xQJJv86M8IqgwWfZl2hqiIcYZSb7VKacGcGx1Q
43ylc4VuFpp1NknP4EhXT5PCnT/AlK83E6q/o4f9AoGALXUEFdLApWFFPuKnt/x9
ueWr+bTd7tfktdEhck4AXKZrLyS14+eUbpcCcRBHY1MC3Ign57T8lQQMslc2rZ3i
OP/6L947e8IVNbYb1Y+1zQihrOXFoie5sp14UfQvTzjCiGit7PG9aDU909qSGx6E
eihvGc76yBK822Dmr0FvJ9UCgYAL4XnAjGyOVs7jzmnfQIWsSvqd3nvDB2CjyKqT
RspJ6ywB56yrRCHGZDP4mcP2P0wdSGm32/Pkkek+gHNjZo+40dM9fo4YTJpDsRUB
+5Se8GFF4W4feTjAPQFspyw3ZOvCDunqs8F6QqCbT1KVixXvfTjGrqXT/+FjsDk+
xgIyyQKBgQC67PW7l32hhelpSpZTDnsvfivDa6+Kw7sfpJxLQDR2/wp9F7K0vsPg
5QTPPhKf7fppa/4PMvO8EFlmLFB7aj8jIBm49eGXzrzQvMZzJlCpzE/qbi1wDPbT
7W2jG23z7MV8hlvft/jOzpXWft+igy4q0fx5qENAQs+nCHhtV5dK0w==";
        $aop = new AopClient ();
        $aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
        $aop->appId = '2018082161143173';
        $aop->rsaPrivateKey = str_replace(array("\r\n", "\r", "\n"), "", $rsaPrivateKey);  
        $aop->alipayrsaPublicKey='MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAn0DVYzNXhwFBAgfAfD7QP/h+1DmzFxXrDpjLEY/98VNDK6gDqTClF+Q6jqfv5ny/coyxl4vQfJYfUxJA+LXIQ0r+/M9GVGCYH7NtOQSmYKPvnZNV2jzMGZNFX1Unf5vn6hjM5briY5+Thu7L4iXzhv7tafdgvAqqEGMqb9OJdktNc6dXhCX/4vi+i3lXZQrlZv/+FSRuOqxuVpR2z02eWaUCpzJUoAPVwOnt1EVypsiDQQNtZJ8rYF3tMyhQeFNVEwE6qTF18UkflC1QldWE80wtidHA/b/DyUVivI2eniXaj5As7W1ZLXjmuQK43tg+C9VpBRN+Ew9irBcwKynZJwIDAQAB';
        $aop->apiVersion = '1.0';
        $aop->signType = 'RSA2';
        $aop->postCharset='utf-8';
        $aop->format='json';
        $request = new AlipayTradeQueryRequest ();
        $request->setBizContent("{" .
        "\"trade_no\":\"2018082422001161091000952616\"" .
        "  }");
        $result = $aop->execute ( $request); 

        $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
        $resultCode = $result->$responseNode->code;
        if(!empty($resultCode)&&$resultCode == 10000){
        echo "成功";
        } else {
        echo "失败";
        }
        return $response;
    }

}
